package  sum;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ChoiceDialog;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import java.util.Arrays;
import java.util.List;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.beans.binding.Bindings;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;

 class MainPage extends Application {
    // 工具方法：创建带图片的按钮
    private Button createIconButton(String imagePath, double size) {
        ImageView icon = new ImageView(new Image(imagePath));
        icon.setFitWidth(size);
        icon.setFitHeight(size);
        icon.setPreserveRatio(true);
        Button btn = new Button();
        btn.setGraphic(icon);
        btn.setStyle("-fx-background-color: transparent;");
        return btn;
    }

    // 工具方法：创建带底图和叠加图标的按钮
    private Button createIconButtonWithOverlay(String baseImagePath, String iconPath, double baseSize, double iconSize) {
        StackPane stack = new StackPane();
        ImageView base = new ImageView(new Image(baseImagePath));
        base.setFitWidth(baseSize);
        base.setFitHeight(baseSize);
        base.setPreserveRatio(true);
        ImageView icon = new ImageView(new Image(iconPath));
        icon.setFitWidth(iconSize);
        icon.setFitHeight(iconSize);
        icon.setPreserveRatio(true);
        stack.getChildren().addAll(base, icon);
        Button btn = new Button();
        btn.setGraphic(stack);
        btn.setStyle("-fx-background-color: transparent;");
        return btn;
    }

    @Override
    public void start(Stage stage) {
        StackPane root = new StackPane();
        // 设置主页面背景，支持动图和自适应窗口
        ImageView bg = new ImageView(new Image("file:assets/bg-0.gif"));
        bg.setPreserveRatio(false);
        root.getChildren().add(bg);

        // 左下角竖排按钮
        Button vbtn1 = createIconButtonWithOverlay("file:assets/button.png", "file:assets/paper-plane.png", 60, 40);
        Button vbtn2 = createIconButton("file:assets/button.png", 60);
        Button vbtn3 = createIconButton("file:assets/button.png", 60);
        VBox vbox = new VBox(20, vbtn1, vbtn2, vbtn3);
        vbox.setAlignment(javafx.geometry.Pos.BOTTOM_LEFT);
        vbox.setPadding(new javafx.geometry.Insets(0, 0, 40, 40));
        root.getChildren().add(vbox);
        StackPane.setAlignment(vbox, javafx.geometry.Pos.BOTTOM_LEFT);

        // 右上角横排按钮
        Button hbtn1 = createIconButton("file:assets/music.png", 60);
        Button hbtn2 = createIconButton("file:assets/menu.png", 60);
        Button hbtn3 = createIconButton("file:assets/button.png", 60);
        HBox hbox = new HBox(20, hbtn1, hbtn2, hbtn3);
        hbox.setAlignment(javafx.geometry.Pos.TOP_RIGHT);
        hbox.setPadding(new javafx.geometry.Insets(40, 40, 0, 0));
        root.getChildren().add(hbox);
        StackPane.setAlignment(hbox, javafx.geometry.Pos.TOP_RIGHT);

        Scene scene = new Scene(root, 800, 600);
        bg.fitWidthProperty().bind(scene.widthProperty());
        bg.fitHeightProperty().bind(scene.heightProperty());
        stage.setTitle("云间飞羽志 - 主页面");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
} 